Minor modifications

Rishabh Jain 11 jaren geleden
bovenliggende
commit
3d76e3990e

+ 1 - 5
app/models/agents/post_agent.rb

@@ -30,11 +30,7 @@ module Agents
30 30
         def post_event(uri,event)
31 31
             req = Net::HTTP::Post.new(uri.request_uri)
32 32
             req.form_data = event
33
-            if uri.scheme == "https"
34
-                Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) { |http| http.request(req) }
35
-            else
36
-                Net::HTTP.start(uri.hostname, uri.port) { |http| http.request(req) }
37
-            end
33
+            Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == "https") { |http| http.request(req) }
38 34
         end
39 35
 
40 36
         def receive(incoming_events)

+ 0 - 5
deployment/Vagrantfile

@@ -2,10 +2,8 @@
2 2
 # vi: set ft=ruby :
3 3
 
4 4
 Vagrant.configure("2") do |config|
5
-  # Every Vagrant virtual environment requires a box to build off of.
6 5
   config.omnibus.chef_version = :latest
7 6
   config.vm.define :vb do |vb|
8
-  # vagrant up vb
9 7
     vb.vm.box = "precise32"
10 8
     vb.vm.box_url = "http://files.vagrantup.com/precise32.box"
11 9
     vb.vm.network :forwarded_port, host: 3000, guest: 3000
@@ -28,9 +26,6 @@ Vagrant.configure("2") do |config|
28 26
   end
29 27
 
30 28
   config.vm.define :ec2 do |ec2|
31
-  # vagrant plugin install vagrant-aws
32
-  # vagrant plugin install vagrant-omnibus   -- So as to make sure chef is installed on ec2 instance
33
-  # vagrant up ec2 --provider=aws
34 29
     ec2.vm.box = "dummy"
35 30
     ec2.vm.box_url = "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box"
36 31
 

+ 39 - 19
deployment/site-cookbooks/huginn_development/recipes/default.rb

@@ -1,44 +1,64 @@
1 1
 include_recipe 'apt'
2 2
 include_recipe 'build-essential'
3 3
 
4
+user "huginn" do
5
+  action :create
6
+  system true
7
+  home "/home/huginn"
8
+  password "$6$ZwO6b.6tij$SMa8UIwtESGDxB37NwHsct.gJfXWmmflNbH.oypwJ9y0KkzMkCdw7D14iK7GX9C4CWSEcpGOFUow7p01rQFu5."
9
+  supports :manage_home => true
10
+  gid "sudo"
11
+  shell "/bin/bash"
12
+end
13
+
14
+group "huginn" do
15
+  members ["huginn"]
16
+  action :create
17
+end
18
+
4 19
 %w("ruby1.9.1" "ruby1.9.1-dev" "libxslt-dev" "libxml2-dev" "curl").each do |pkg|
5 20
   package pkg do
6 21
     action :install
7 22
   end
8 23
 end
9 24
 
10
-git "/usr/local/huginn" do
25
+git "/home/huginn/huginn" do
11 26
   repository 'git://github.com/cantino/huginn.git'
12 27
   reference 'master'
13 28
   action :sync
29
+  user "huginn"
14 30
 end
15 31
 
16 32
 gem_package("rake")
17 33
 gem_package("bundle")
18 34
 
35
+bash "Setting huginn user with NOPASSWD option" do
36
+  cwd "/etc/sudoers.d"
37
+  code <<-EOH
38
+    touch huginn
39
+    chmod 0440 huginn
40
+    echo "huginn ALL=(ALL) NOPASSWD:ALL" >> huginn
41
+    EOH
42
+end
43
+
19 44
 bash "huginn dependencies" do
20
-  user "root"
21
-  cwd "/usr/local/huginn"
45
+  user "huginn"
46
+  cwd "/home/huginn/huginn"
22 47
   code <<-EOH
23 48
     export LANG="en_US.UTF-8"
24 49
     export LC_ALL="en_US.UTF-8"
25
-    bundle install
26
-    sed s/REPLACE_ME_NOW\!/$(rake secret)/ .env.example > .env
27
-    rake db:create
28
-    rake db:migrate
29
-    rake db:seed
50
+    sudo bundle install
51
+    sed s/REPLACE_ME_NOW\!/$(sudo rake secret)/ .env.example > .env
52
+    sudo rake db:create
53
+    sudo rake db:migrate
54
+    sudo rake db:seed
30 55
     EOH
31 56
 end
32 57
 
33
-#log "huginn start" do
34
-#  level :info 
35
-#  message "Huginn has been installed and wil start at your instance in two minutes"
36
-#end
37
-
38
-bash "Huginn has been installed and server will start in a minute" do
39
- user "root"
40
- cwd "/usr/local/huginn"
41
- code <<-EOH
42
-   sudo foreman start
43
- EOH
58
+bash "huginn has been installed and will start in a minute" do
59
+  user "huginn"
60
+  cwd "/home/huginn/huginn"
61
+  code <<-EOH
62
+    sudo foreman start
63
+    EOH
44 64
 end

+ 1 - 1
deployment/site-cookbooks/huginn_production/files/default/nginx.conf

@@ -1,5 +1,5 @@
1 1
 #worker_process 2;
2
-#user huginn huginn;
2
+user huginn huginn;
3 3
 
4 4
 events { 
5 5
   worker_connections 1024;

+ 4 - 2
deployment/site-cookbooks/huginn_production/recipes/default.rb

@@ -80,7 +80,9 @@ end
80 80
 bash "Setting huginn user with NOPASSWD option" do
81 81
   cwd "/etc/sudoers.d"
82 82
   code <<-EOH
83
-    echo 'huginn ALL=(ALL) NOPASSWD:ALL' >> 90-cloudimg-ubuntu
83
+    touch huginn
84
+    chmod 0440 huginn 
85
+    echo "huginn ALL=(ALL) NOPASSWD:ALL" >> huginn
84 86
   EOH
85 87
 end
86 88
 
@@ -98,4 +100,4 @@ bash "huginn dependencies" do
98 100
     sudo foreman export upstart /etc/init -a huginn -u huginn
99 101
     sudo start huginn
100 102
     EOH
101
-end
103
+end